package com.centling.smartSealForPhone.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author fionera
 */
public class PhoneNumCheck {
    private static Pattern usernamePattern = Pattern.compile("[a-zA-Z0-9\u4e00-\u9fa5]$");
    private static Pattern phonePattern = Pattern.compile("^(13|14|15|17|18)[0-9]{9}$");

    public static boolean isUsername(String str) {
        boolean isUsername = false;
        if (str.length() == 11) {
            try {
                Matcher m = usernamePattern.matcher(str);
                isUsername = m.matches();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return isUsername;
    }

    public static boolean isMobileNo(String str) {
        boolean isMobileNo = false;
        if (str.length() == 11) {
            try {
                Matcher m = phonePattern.matcher(str);
                isMobileNo = m.matches();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return isMobileNo;
    }
}
